# Virtual Router Simulator 
#
# Copyright (C) 2009-2010 VRSim Project
# Author: Choonho Son <choonho@kt.com>
# URL: <http://vrsim.googlecode.com>
# For license information, see LICENSE.TXT
#

import re
from VRSim.Node.Router import Router
#from VRSim.Node.CiscoDomain import CiscoDomain

#class Cisco(Router,  CiscoDomain):
class Cisco(Router):
    def __init__(self,  nodeid):
        Router.__init__(self,  nodeid)
        #CiscoDomain.__init__(self,  nodeid)
        self.model = "Cisco"
        self.hostname = "Cisco"
        self.idlepc_count = 0
        
    def updateIdlepc(self):
        # get idlepc
        values = self.getIdlepc()
        print values
        min = 100
        idlepc = ""
        for item in values:
            index = item.split(" ")
            cpu = (re.search("\d+",  index[2])).group()
            if int(cpu) < min:
                min = int(cpu)
                idlepc = index[1]
        
        print (min,  idlepc)
        # update Config windows
        self.idlepc = idlepc
        #self.pnode.idlepc = idlepc
        #self.lineEdit_Idlepc.setText(idlepc)
        
        # call setIdlepc for router
        self.setIdlepc(idlepc)
